<?php
namespace app\models;

use yii\base\Model;
use yii\web\UploadedFile;
use yii\db\ActiveRecord;

/**
 * UploadForm is the model behind the upload form.
 */
class UploadForm extends Model
{
    /**
     * @var UploadedFile file attribute
     */
    public $file;

    /**
     * @return array the validation rules.
     */
    public function rules()
    {
        return [
            //  上传类型，不仅可以根据扩展名检验，还可以根据文件的内容进行检验
            [['file'], 'file', 'extensions' => 'jpg, png', 'mimeTypes' => 'image/jpeg, image/png',],
            //一次上传多个文件
            //[['file'], 'file', 'maxFiles' => 10],
        ];
    }
    public function attributeLabels()
    {
        return [
            'file' => '上传凭证',
        ];
    }
    /**
     * 关联套餐
     * @return \yii\db\ActiveQuery
     */
    public function getPackage()
    {
        return $this->hasOne(Package::class, ['id' => 'package_id']);
    }
}
